import math
import collections


class Solution(object):
    def trailingZeroes(self, n):
        """
        :type n: int
        :rtype: int
        """
        a = n
        value = 0
        value_dict = collections.defaultdict(int)
        value_dict[0] = 0
        flag = True
        while a >= 5:
            b = int(math.log(a, 5))
            if pow(5, b + 1) == a:
                b = b + 1
            if flag:
                for i in range(1, b + 1):
                    value_dict[i] = 5 * value_dict[i - 1] + 1
                flag = False
            value += (a // pow(5, b)) * value_dict[b]
            a = a % pow(5, b)
        return value


data = Solution()
n = 1500
print(data.trailingZeroes(n))
